#pragma once

#include "CBaseNode.h"
#include "CTweenNode.h"

using namespace cocos2d;

#define  ANGLE_TO_RADIAN  (M_PI / 180)


class CCBone : public CCObject
{
public:
	
	static CCBone* create(bool _isRadian = false);

	static void	removePoolObject();

protected:

	static CCArray	*sObjectPool;

	static int		sPoolIndex;

	static void		recycle(CCBone* _bone);
	

public:

	
	CCBone();
	~CCBone(void);

	virtual bool init(bool _isRadian);

	
    void	remove();

	
	void	addBoneChild(CCBone* _child);
    
    void	setLockPosition(float _x, float _y, float _skewX = 0, float _skewY = 0);

	void	update( float dt );

	float	 getGlobalX();

	float	getGlobalY();

	float	getGlobalR();
	float	getGlobalSkewX();
	float	getGlobalSkewY();


protected:


	void updateDisplay();

	void reset();

public:

	
	CC_SYNTHESIZE(const char *, mName, Name);
	

	CC_SYNTHESIZE_RETAIN(CCNode	*, mDisplay, Display);


	CC_SYNTHESIZE_RETAIN(CCBaseNode	*, mNode, Node);


	CC_SYNTHESIZE_RETAIN(CCTweenNode *, mTweenNode, TweenNode);

	CC_SYNTHESIZE(CCBone *, mParent, Parent);
	CC_SYNTHESIZE_PASS_BY_REF(std::string, mParentName, ParentName);

protected:
	
	bool	mIsRadian;
	float	mTransformX;
	float	mTransformY;
	float	mTransformSkewX;
	float	mTransformSkewY;
	float	mTransformRotation;
	float	mLockX;
	float	mLockY;
	float	mLockR;
	float	mLockSkewX;
	float	mLockSkewY;
	float	mParentX;
	float	mParentY;
	float	mParentR;
	float	mParentSkewX;
	float	mParentSkewY;

};

